<?php

namespace App\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
    protected $dateFormat = 'U';

    protected $attributes = [
        'url'           => '',
        'reply_content' => '',
    ];

    protected $fillable = [
        'article_id',
        'content',
        'name',
        'email',
        'url',
        'avatar',
    ];

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function article()
    {
        return $this->belongsTo(Article::class);
    }
}
